// routerGuard.ts  
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router';  

//导航守卫
export default function (router: import('vue-router').Router) {  
  router.beforeEach((to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {
    //需要登录
    if(to.meta.auth){
      if(!localStorage.getItem('token')){
        next('/')
      }else{
        next()
      }
    }else{
      next()
    }
  
  })
}